﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using h = functionService.shorts;
using da = functionService.DATECOD;
using fr = HK.FiscalRegistrar.FiscalRegistrar;
using vv = functionService.serfun_city7;
using tg = functionService.tagWork;
namespace ETALON
{
    public partial class FormDocZ : Form
    {
        ClassFormDocZ c;
        Tool toolF;
        string sm;

        public FormDocZ() 
        { 
            InitializeComponent();
            toolF = new 
                Tool
                (toolStripMenuItem12,
                toolStripMenuItem2, toolStripMenuItem3,toolStripMenuItem4,toolStripMenuItem5,toolStripMenuItem6,toolStripMenuItem7,
                toolStripButton1,toolStripButton2,toolStripButton3,toolStripButton4,toolStripButton5,toolStripButton6,
                toolStripButton8,
                toolStripMenuItem1,
                toolStripStatusLabel1, this.toolStripStatusLabel2, this.toolStripStatusLabel3, 
                listView2,listView3 
                );
            c = new ClassFormDocZ(toolF);
            sm = c.q.tk(param.day_work_7);
            this.Text = functionService.shorts.a("Рабочий день: ", sm);
            string s = c.q.tk(param.bknowCod_60); 
            if (s == "1") 
            { vv.codKol.bKnowCod = true; } 
            else { vv.codKol.bKnowCod = false; } 
            setKnowCod();

            vv.rd.year = Convert.ToDateTime(sm).Year;
            vv.rd.month = Convert.ToDateTime(sm).Month ;
            vv.rd.day = Convert.ToDateTime(sm).Day;
        }
        public FormDocZ(int indexDoc):this()
        {
           c.selectOnIndex(indexDoc);
           c.setModeWAED(ETALON.raw.modeWAED.loadForReadOnly);
        }

    
        

        private void toolStripButton3_Click(object sender, EventArgs e)
        {
           c.addDoc(2);
        }

        private void toolStripButton4_Click(object sender, EventArgs e)
        {
            c.delDoc();
        }

        private void toolStripButton6_Click(object sender, EventArgs e)
        {
            c.editDoc();
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            if (c.currentTypeDoc == ETALON.raw.typeDoc.NKP ||
                c.currentTypeDoc == ETALON.raw.typeDoc.NKRS )
            {
                c.addDocTd_SkladNk2();
            }
            else if (c.currentTypeDoc == ETALON.raw.typeDoc.NKR)
            {
                c.addDocTd();
            }
        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            c.deleteSir();
        }

        private void toolStripButton5_Click(object sender, EventArgs e)
        {
           // c.q.sh(c.td);
            c.editDocTd();
        }

        private void toolStripMenuItem40_Click(object sender, EventArgs e)
        {
            ETALON.FormCreateFileParam f = new ETALON.FormCreateFileParam(); f.ShowDialog();

        }

        private void toolStripMenuItem1_Click(object sender, EventArgs e)
        {

        }

        private void toolStripMenuItem8_Click(object sender, EventArgs e)
        {
            c.toolStripMenuItem8Click_2();
        }

        private void toolStripButton7_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void toolStripMenuItem7_Click(object sender, EventArgs e)
        {

        }

        private void toolStripMenuItem2_Click(object sender, EventArgs e)
        {
            c.setModeTypeDoc(ETALON.raw.typeDoc.NKP, ETALON.raw.typeDocOP.no);
        }

        private void toolStripMenuItem4_Click(object sender, EventArgs e)
        {
            //c.setModeTypeDoc(ETALON.raw.typeDoc.SFP);
        }

        private void toolStripMenuItem5_Click(object sender, EventArgs e)
        {
           // c.setModeTypeDoc(ETALON.raw.typeDoc.SFR);
        }

        private void toolStripMenuItem6_Click(object sender, EventArgs e)
        {
            c.setModeTypeDoc(ETALON.raw.typeDoc.NKR);
        }

        private void listView3_SelectedIndexChanged(object sender, EventArgs e)
        {

            try { c.listView3_Select(); }
            catch { }
        }

        private void listView2_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
        {
            c.selectSir();
        }

        private void toolStripMenuItem9_Click(object sender, EventArgs e)
        {
            c.setModeTypeDoc(ETALON.raw.typeDoc.NKP, ETALON.raw.typeDocOP.prihSklad );
        }

        private void toolStripMenuItem10_Click(object sender, EventArgs e)
        {
            c.setModeTypeDoc(ETALON.raw.typeDoc.NKP, ETALON.raw.typeDocOP.ost );
        }

        private void toolStripMenuItem9_Click_1(object sender, EventArgs e)
        {
            
        }

        private void toolStripMenuItem11_Click(object sender, EventArgs e)
        {
            setKnowCod();
        }

        private void setKnowCod()
        {
            if (vv.codKol.bKnowCod) { toolStripMenuItem11.Checked = false; vv.codKol.bKnowCod = false; c.q.put(param.bknowCod_60, 0); }
            else { toolStripMenuItem11.Checked = true; vv.codKol.bKnowCod = true; c.q.put(param.bknowCod_60, 1); }
        }

        

        private void toolStripMenuItem10_Click_1(object sender, EventArgs e)
        {
            setEnterEnter();
        }

        private void setEnterEnter()
        {
            if (vv.codKol.enterEnter) { toolStripMenuItem10.Checked = false; vv.codKol.enterEnter = false; }
            else { toolStripMenuItem10.Checked = true; vv.codKol.enterEnter = true; }
        }

        private void toolStripMenuItem12_Click(object sender, EventArgs e)
        {
            c.setModeTypeDoc(ETALON.raw.typeDoc.NKRS, ETALON.raw.typeDocOP.no);
        }

        private void toolStripButton8_Click(object sender, EventArgs e)
        {
            city7.FormDocLook f = new city7.FormDocLook((int)city7.opro.lookAnyDoc ); f.ShowDialog();
        }
        
        
        
       



       
    }
}
